﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Client
{
    public partial class CreateAccountForm : System.Windows.Forms.Form
    {
        public CreateAccountForm()
        {
            InitializeComponent();
        }

        private void btnJoin_Click(object sender, EventArgs e)
        {
            // 비밀번호 일치 확인
            if (txtPswd.Text != txtPswd_Re.Text)
            {
                MessageBox.Show("비밀번호가 일치하지 않습니다.");
                return;
            }

            // 서버로 회원정보 전송
            CCL.SocketMessage.Request.Join packet = new CCL.SocketMessage.Request.Join(txtEMail.Text, txtPswd.Text, txtName.Text);
            CCL.SocketMessage.Message message = CCL.SocketMessage.Message.MessageRequestBuilder(packet);
            byte[] msg = message.GetByte();

            // 송신
            CCL.SocketMessage.Message recvMsg = MainForm.connector.Execute(msg);

            CCL.SocketMessage.Response.Join joinMsg = (CCL.SocketMessage.Response.Join)recvMsg.Body;

            if (joinMsg.Result == CCL.SocketMessage.Constant.Result.Success)
            {
                MessageBox.Show("회원가입이 되었습니다.");
            }
            else
            {
                MessageBox.Show(CCL.Utility.StringUtility.ConvertToStr(joinMsg.ErrorMessage));
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            // 취소버튼을 누르면
            // Form 을 종료함.
            this.Close();
        }
    }
}
